package com.study.utils;


import cn.hutool.core.util.IdUtil;
import lombok.Data;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.MutablePair;
import org.junit.jupiter.api.Test;

import java.time.LocalDate;

/**
 * @author zhuzi
 * 2024/11/27 16:8
 */
@Slf4j
public class ApacheDemo {
    @Test
    public void toStr() {
        Stu stu = new Stu();
        String s = ToStringBuilder.reflectionToString(stu);
        System.out.println(s);

        try {
            System.out.println(1 / 0);
            System.out.println(stu.toString());
        } catch (Exception e) {
            log.error("爆出来啊[{}]", LocalDate.now(), e);
        }
    }

    @Data
    @Accessors(chain = true)
    public static class Stu {
        private String name = "哈哈";
        private Long id = IdUtil.getSnowflakeNextId();
    }

    /**
     * https://mp.weixin.qq.com/s/kWVD0kBjNnPoMUqo0j6o0g
     * 多值
     */
    @Test
    public void tuple() {
        //可变，非线程安全。
        MutablePair<String, Integer> pair = MutablePair.<String, Integer>of("userID", 25);
        pair.setRight(30); // 修改右值

        // 不可变
        ImmutablePair<String, Integer> pairImmu = ImmutablePair.of("userID", 25);

    }
}
